<template>
  <div class="div3" id="div3">
    <el-table :data="tableData"  style="width: 100%">
      <el-table-column label="序号" prop="courseId" width="80" />
      <el-table-column label="课程名" prop="title"  width="100" />
      <el-table-column label="课程封面" prop="cover" width="150" >
        <template #default="scope">
          <div class="demo-image__preview">
            <el-image
                style="width: 100px; height: 100px"
                :src="scope.row.cover"
                :preview-teleported="true"
                :hide-on-click-modal="true"
                :zoom-rate="1.2"
                :initial-index="4"
                fit="cover"
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="课程描述" prop="description"  width="220" />
      <el-table-column label="教师" prop="teaName"  width="60" />

      <el-table-column label="操作" width="500">
        <template #default="scope">
          <el-button type="success" size="small"  @click="courseChapter(scope)" >章节详情</el-button>
          <el-button type="success" size="small"  @click="courseEdit(scope)" >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {ref} from "vue";
export default {
  name: "TeaCourse",
  data() {
    return {
      srcList: [],
      courseTitle: '',
      dialogTableVisible: ref(false),
      tableData: [],
      gridData: [],
      gridDataWork: [],
      dialogTableVisible2: ref(false),

    }
  },
  created() {
    this.courseList();
  },

  methods: {
    courseChapter(scope){
      // this.$parent.active=1
      this.$router.push({path:'CourseEdit',query:{courseId:scope.row.courseId,title:scope.row.title}})

      // this.$router.push({path:'CourseEdit',query:{id:'1'}})
      // this.$router.push({name:'CourseEdit',query:{id:'1'}})
      // console.log("9999999",scope.row.courseId)

    },
    courseEdit(scope){

    },
    courseList(){
      let _this = this;
      let url = "/studyadmin/course/courseList";
      _this.$axios.post(url).then(function(serverData){
        // console.log("服务端返回的kecheng 数据为:",serverData);
        if(serverData.data.code===0){
          // let courseList = serverData.data.data;
          _this.tableData=serverData.data.data;

          // console.log("-=-=--=",_this.tableData)
          // _this.tableData.date=courseList.title
        }
      }).catch(function(error){
        console.log("异步请求发生了错误:",error);
      })
    }

  },
}
</script>

<style scoped>

</style>
